namespace Bowlus.Common.Logging
{
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;

    public class Logger : ILogger
    {
        public void Write(TraceSource source, TraceEventType eventType, int eventId, string message)
        {
            if (null != source)
            {
                source.TraceData(eventType, eventId, message);
            }
        }

        public void Write(IEnumerable<string> sources, TraceEventType eventType, int eventId, string message, IDictionary<string, object> data)
        {
            // TODO: format the data into the message too
            foreach (var traceSource in sources.Select(source => new TraceSource(source, SourceLevels.All)))
            {
                traceSource.TraceData(eventType, eventId, message);
            }
        }

        public void Write(string source, TraceEventType eventType, int eventId, string message, IDictionary<string, object> data)
        {
            this.Write(new[] { source }, eventType, eventId, message, data);
        }
    }
}